//
//  CBJStatues.swift
//  Weibo
//
//  Created by 崔健 on 16/5/24.
//  Copyright © 2016年 cbj. All rights reserved.
//

import UIKit

class CBJStatues: NSObject {
    
    
    //4 4s 5 5c 都是32的
    //之后的都是 64位
    var id: Int64 = 0
    ///微博信息内容
    var text: String?
    ///微博创建时间
    var created_at: String?
    ///微博来源
    var source: String?
    //用户  直接赋值 会给自定义对象赋值一个字典
    var user: CBJUser?
    
    var retweeted_status : CBJStatues?
    
    //配图视图的模型数组
    var pic_urls: [CBJPicture]?
    
    init(dict : [String : AnyObject]) {
        
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) { }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            
            if let dict = value as? [String : AnyObject] {
                
                user = CBJUser(dict: dict)
            }
            
            return
        }
        
        if key == "retweeted_status" {
            
            if let dict = value as? [String : AnyObject] {
                
                retweeted_status = CBJStatues(dict: dict)
            }
            
            return
        }
        
        
        if key == "pic_urls" {
            
            var tempArray = [CBJPicture]()
            if let array = value as? [[String : AnyObject]] {
                
                for item in array{
                    
                    tempArray.append(CBJPicture(dict: item))

                }
                
                pic_urls = tempArray
            }
            
            return
        }
        
        super.setValue(value, forKey: key)
    }
    
}
